#include "exportthread.h"
#include <QFile>
#include<QThread>
#include<QDebug>
#include <QTextStream>
void ExportThread::run()
{
    qDebug()<<"当前线程..."<<QThread::currentThread();
    QFile file(m_filePath);
    bool ok = false;
    if (file.open(QIODevice::WriteOnly | QIODevice::Text))
    {
        QTextStream out(&file);
        // 将日志按行分割，逐行写入并发送进度
        QStringList lines = m_text.split("\n");
        int totalLines = lines.size();

        for (int i = 0; i < totalLines; ++i)
        {
            out << lines[i] << "\n";
            int percent = (i + 1) * 100 / totalLines;
            emit progressChanged(percent);  // 发进度信号
        }

        file.close();
        ok = true;
    }
    emit exportFinished(ok); // 通知导出结束
}
